package org.hdax.service.impl;

import org.hdax.dao.RolePermissionDao;
import org.hdax.entity.RolePermission;
import org.hdax.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RolePermissionServiceImpl implements RolePermissionService {

    @Autowired
    private RolePermissionDao rolePermissionDao;

    @Override
    public boolean deleteByRoleId(int role_id) {
        boolean isUpdate = false;
        try {
            rolePermissionDao.deleteByRoleId(role_id);
            isUpdate = true;
        }catch (Exception e){
            e.printStackTrace();
            isUpdate = false;
        }
        return isUpdate;
    }

    @Override
    public boolean saveEntity(RolePermission rolePermission) {
        boolean isSave = false;
        try {
            rolePermissionDao.saveEntity(rolePermission);
            isSave = true;
        }catch (Exception e){
            e.printStackTrace();
            isSave = false;
        }
        return isSave;
    }
}
